package com.cs157a.dao;

import java.io.*;

/**
 * AplCar Value Object. This class is value object representing database table
 * AplCar This class is intented to be used together with associated Dao object.
 */

public class AplCar implements Cloneable, Serializable {

	private static final long serialVersionUID = 20012100301L;

	/**
	 * Persistent Instance variables. This data is directly mapped to the
	 * columns of database table.
	 */
	String Make;
	private String Model;
	private String Year;
	private String Description;
	private String Litres;
	private String EngineType;
	private String CubicInches;
	private int Rlink;

	/**
	 * Constructors. DaoGen generates two constructors by default. The first one
	 * takes no arguments and provides the most simple way to create object
	 * instance. The another one takes one argument, which is the primary key of
	 * the corresponding table.
	 */

	public AplCar() {

	}

	public AplCar(String ModelIn, String YearIn, String DescriptionIn,
			String LitresIn, String EngineTypeIn, String CubicInchesIn) {

		this.Model = ModelIn;
		this.Year = YearIn;
		this.Description = DescriptionIn;
		this.Litres = LitresIn;
		this.EngineType = EngineTypeIn;
		this.CubicInches = CubicInchesIn;

	}

	/**
	 * Get- and Set-methods for persistent variables. The default behaviour does
	 * not make any checks against malformed data, so these might require some
	 * manual additions.
	 */

	public String getModel() {
		return this.Model;
	}

	public void setModel(String ModelIn) {
		this.Model = ModelIn;
	}

	public String getYear() {
		return this.Year;
	}

	public void setYear(String YearIn) {
		this.Year = YearIn;
	}

	public String getDescription() {
		return this.Description;
	}

	public void setDescription(String DescriptionIn) {
		this.Description = DescriptionIn;
	}

	public String getLitres() {
		return this.Litres;
	}

	public void setLitres(String LitresIn) {
		this.Litres = LitresIn;
	}

	public String getEngineType() {
		return this.EngineType;
	}

	public void setEngineType(String EngineTypeIn) {
		this.EngineType = EngineTypeIn;
	}

	public String getCubicInches() {
		return this.CubicInches;
	}

	public void setCubicInches(String CubicInchesIn) {
		this.CubicInches = CubicInchesIn;
	}

	public int getRlink() {
		return this.Rlink;
	}

	public void setRlink(int RlinkIn) {
		this.Rlink = RlinkIn;
	}

	/**
	 * setAll allows to set all persistent variables in one method call. This is
	 * useful, when all data is available and it is needed to set the initial
	 * state of this object. Note that this method will directly modify instance
	 * variales, without going trough the individual set-methods.
	 */

	public void setAll(String ModelIn, String YearIn, String DescriptionIn,
			String LitresIn, String EngineTypeIn, String CubicInchesIn,
			int RlinkIn) {
		this.Model = ModelIn;
		this.Year = YearIn;
		this.Description = DescriptionIn;
		this.Litres = LitresIn;
		this.EngineType = EngineTypeIn;
		this.CubicInches = CubicInchesIn;
		this.Rlink = RlinkIn;
	}

	/**
	 * hasEqualMapping-method will compare two AplCar instances and return true
	 * if they contain same values in all persistent instance variables. If
	 * hasEqualMapping returns true, it does not mean the objects are the same
	 * instance. However it does mean that in that moment, they are mapped to
	 * the same row in database.
	 */
	public boolean hasEqualMapping(AplCar valueObject) {

		if (this.Model == null) {
			if (valueObject.getModel() != null)
				return (false);
		} else if (!this.Model.equals(valueObject.getModel())) {
			return (false);
		}
		if (this.Year == null) {
			if (valueObject.getYear() != null)
				return (false);
		} else if (!this.Year.equals(valueObject.getYear())) {
			return (false);
		}
		if (this.Description == null) {
			if (valueObject.getDescription() != null)
				return (false);
		} else if (!this.Description.equals(valueObject.getDescription())) {
			return (false);
		}
		if (this.Litres == null) {
			if (valueObject.getLitres() != null)
				return (false);
		} else if (!this.Litres.equals(valueObject.getLitres())) {
			return (false);
		}
		if (this.EngineType == null) {
			if (valueObject.getEngineType() != null)
				return (false);
		} else if (!this.EngineType.equals(valueObject.getEngineType())) {
			return (false);
		}
		if (this.CubicInches == null) {
			if (valueObject.getCubicInches() != null)
				return (false);
		} else if (!this.CubicInches.equals(valueObject.getCubicInches())) {
			return (false);
		}
		if (valueObject.getRlink() != this.Rlink) {
			return (false);
		}

		return true;
	}

	/**
	 * toString will return String object representing the state of this
	 * valueObject. This is useful during application development, and possibly
	 * when application is writing object states in textlog.
	 */
	public String toString() {
		StringBuffer out = new StringBuffer("");
		// out.append("\nclass AplCar, mapping to table AplCar\n");
		out.append("Persistent attributes: \n");
		out.append("Make = " + this.Make + "\n");
		out.append("Model = " + this.Model + "\n");
		out.append("Year = " + this.Year + "\n");
		out.append("Description = " + this.Description + "\n");
		out.append("Litres = " + this.Litres + "\n");
		out.append("EngineType = " + this.EngineType + "\n");
		out.append("CubicInches = " + this.CubicInches + "\n");
		out.append("Rlink = " + this.Rlink + "\n");
		return out.toString();
	}

	/**
	 * Clone will return identical deep copy of this valueObject. Note, that
	 * this method is different than the clone() which is defined in
	 * java.lang.Object. Here, the retuned cloned object will also have all its
	 * attributes cloned.
	 */
	public Object clone() {
		AplCar cloned = new AplCar();

		if (this.Model != null)
			cloned.setModel(new String(this.Model));
		if (this.Year != null)
			cloned.setYear(new String(this.Year));
		if (this.Description != null)
			cloned.setDescription(new String(this.Description));
		if (this.Litres != null)
			cloned.setLitres(new String(this.Litres));
		if (this.EngineType != null)
			cloned.setEngineType(new String(this.EngineType));
		if (this.CubicInches != null)
			cloned.setCubicInches(new String(this.CubicInches));
		cloned.setRlink(this.Rlink);
		return cloned;
	}

}
